package com.go8.mall;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.go8.mall.pojo.Cart;

/**
 * 服务端购物车的数据结构：map
 * @author cjl
 *
 */
public class LocalCartCache implements CartCache{
	private Map<Long,List<Cart>> carts;
	
	public LocalCartCache() {
		this.carts = new HashMap<>();
	}

	public Map<Long, List<Cart>> getCarts() {
		return carts;
	}

	public void setCarts(Map<Long, List<Cart>> carts) {
		this.carts = carts;
	}

	@Override
	public List<Cart> getByUserId(long userId) {
		return this.carts.get(userId);
	}

	@Override
	public void setByUserId(long userId, List<Cart> carts) {
		this.carts.put(userId, carts);
	}

	@Override
	public void delByUserId(long userId) {
		this.carts.remove(userId);
	}
}
